<?
namespace xto\data\service;

use xto\data\model\ManagerModel; 
use xto\data\Factory;
use think\Db;
use think\Request;
use xto\Util;
use xto\App;
use xto\membership\context\Users;
use xto\data\model\LogModel;

class LogService{ 
	static function getlist($pagezie){
		$result=array();
		$list = LogModel::order('logid', 'desc')->paginate($pagezie);
		$page = $list->render();
		$result['list']=$list;
		$result['page']=$page;
		return $result;
	}

	static function writelog($description){ 
		$data=[
			'ip' 			=> Util::getip(),
			'description'	=> $description,
			'createdate'	=> Util::getdate(),
			'url'			=> Request::instance()->url(true), 
			'appid'			=> App::appid(),
			'username'		=> Users::getLoginUserNameByManager()
			];
		return LogModel::create($data); 
	}

	static function delete($id){ 
		return Db::table('xto_logs')
			->where('logid',$id)
			->where('appid',App::appid())
			->delete(); 
	}
}